<template>
	<view class="main-container">
		<view class="qrcode-conatainer">
			<view class="qrcode-conatainer-content">
				<image v-if="couponDetail.isUsed==1" :src="couponDisable" class="no-using-image"></image>
				<view class="qrcode-conatainer-title">
					<view class="header-icon"><image :src="greeTreeIcon"></image></view>
					<view class="header-title">绿树网咖</view>
				</view>
				<view class="middle-operation">
					<view class="coupon-name">{{ couponDetail.name }}</view>
					<!-- <button class="coupon-using-btn" :disabled="couponDetail.isUsed==1" @click="clickCustomerCoupon" :class="{ 'coupon-disable-btn': !couponDetail.IsEnabled }">
						立即使用
					</button> -->
				</view>
				<view class="flexc justify-center" style="padding-bottom:30rpx">
					<image style="width: 500rpx;height: 500rpx;" :src="couponDetail.writeOffBase64" mode=""></image>
					<view>向商家出示</view>
				</view>
				<view class="coupon-param-contianer">
					<view class="coupon-detail-item">
						<view class="coupon-detail-item-title">有效日期</view>
						<view class="coupon-detail-item-content">{{ couponDetail.startTime }}至{{ couponDetail.endTime }}</view>
					</view>
					<view class="coupon-detail-item">
						<view class="coupon-detail-item-title">使用范围</view>
						<view class="coupon-detail-item-content">满{{ couponDetail.min }}元可用</view>
					</view>
				<!-- 	<view class="coupon-detail-item">
						<view class="coupon-detail-item-title">可用时间</view>
						<view class="coupon-detail-item-content">{{ couponDetail.okWeek }} {{ couponDetail.okDay }}</view>
					</view> -->
					<view class="coupon-detail-item">
						<view class="coupon-detail-item-title">优惠说明</view>
						<view class="coupon-detail-item-content">{{ couponDetail.couponDesc }}</view>
					</view>
					<view class="coupon-detail-item">
						<view class="coupon-detail-item-title">使用须知</view>
						<view class="coupon-detail-item-content">{{ couponDetail.useDesc }}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getCustomerStoreCouponNewInfoById } from '@/constant/customer.js';
import { errorToShow } from '@/config/common.js';
import greeTreeIcon from '@/static/images/gree-tree-icon.png';
import couponDisable from '@/static/images/coupon-disable.png';
export default {
	data() {
		return {
			greeTreeIcon: greeTreeIcon,
			couponDisable: couponDisable,
			couponDetail: {},
			couponParam: {
				Condition: '无',
				OkDay: '',
				OkWeek: '无',
				Remarks: '无'
			}
		};
	},
	onLoad(option) {
		this.initOptionParam(option);
	},
	methods: {
		initOptionParam(option) {
			if (!option.couponId) {
				this.backBeforePage();
				return;
			}
			this.getCustomerStoreCouponNewInfoById(option.couponId);
		},
		async getCustomerStoreCouponNewInfoById(customerCouponId) {
			
				let result = await getCustomerStoreCouponNewInfoById(customerCouponId);
				if(result.code==0){
					this.couponDetail = result.data;
				}else{
					this.backBeforePage();
				}
				this.couponDetail = result.data;
			
			
		},
		backBeforePage() {
			errorToShow('获取优惠券信息失败', function() {
				uni.navigateBack();
			});
		},
		clickCustomerCoupon() {
			let item = this.couponDetail;
			uni.navigateTo({
				url: './couponQrCode?couponId=' + item.Id + '&name=' + item.Name + '&customerCouponNumber=' + item.CustomerCouponNumber
			});
		}
	}
};
</script>
<style>
	@import url('@/css/common.css');
</style>
<style scoped lang="scss">
.main-container {
	background-color: #389455;
	min-height: 100vh;
	padding-top: 90rpx;
	padding-bottom: 90rpx;
}

.qrcode-conatainer {
	width: 100%;
	display: -webkit-box;
	display: -webkit-flex;
	display: flex;
	justify-content: center;
	min-height: 80vh;
}
.qrcode-conatainer-content {
	width: 90%;
	background-color: #fff;
	min-height: 80%;
	border-radius: 6px;
	box-shadow: darkgrey 0px 2px 6px 0px;
	position: relative;
	.no-using-image {
		height: 130rpx;
		width: 130rpx;
		z-index: 9999;
		position: absolute;
		right: 20rpx;
		top: 20rpx;
	}
}
.qrcode-conatainer-title {
	width: 100%;
	font-size: 32rpx;
	color: #1370cc;
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-bottom: 30rpx;
	.header-title {
		color: $main-text-color-gray-B3;
		font-size: $main-text-size-26;
		margin-top: 10rpx;
	}
	.header-icon {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
		margin-top: -40rpx;
		background-color: #fff;
		margin-bottom: 4rpx;
		image {
			width: 100%;
			height: 100%;
			margin-top: 10rpx;
		}
	}
}

.middle-operation {
	text-align: center;
	margin-bottom: 30rpx;
	.coupon-name {
		font-size: $main-text-size-36;
		font-weight: 600;
		margin-bottom: 30rpx;
	}
	.coupon-using-btn {
		width: 350rpx;
		color: #fff;
		height: 70rpx;
		background-color: $main-theme-color-wechat-green;
		line-height: 70rpx;
		margin: auto;
		border-radius: 6rpx;
		font-size: $main-text-size-28;
	}

	.coupon-disable-btn {
		background-color: #e6e6e6;
		color: $main-text-color-gray-black;
	}
}
.coupon-param-contianer {
	padding: 48rpx 20rpx 0 20rpx;
	font-size: $main-text-size-26;
	border-top: 1px dashed $main-line-color-vertical;
	overflow-y: auto;
	.coupon-detail-item {
		margin-bottom: 10px;
		display: flex;
	}

	.coupon-detail-item-title {
		color: $main-text-color-gray-33;
		margin-right: 10px;
		width: 20%;
	}

	.coupon-detail-item-content {
		color: $main-text-color-gray-black;
		margin-right: 10px;
		width: 80%;
	}
}
</style>
